Skip to content

feat(notification): add provider-agnostic email adapter with templates &n mock provider#152

Merged
ahmadogo merged 1 commit intoMentoNest:mainfrom
mijinummi:feat/email-notification-adapter
Jan 29, 2026
Merged

feat(notification): add provider-agnostic email adapter with templates &n mock provider#152
ahmadogo merged 1 commit intoMentoNest:mainfrom
mijinummi:feat/email-notification-adapter

Conversation

@mijinummi
Copy link
Contributor

✉️ Email Notification Adapter

This PR introduces a provider-agnostic email notification system with support for pluggable providers, templated emails, and a mock provider for development and testing.

🎯 Purpose

Improve notification reliability and flexibility by decoupling email delivery from specific providers while enabling reusable, event-based email templates.


✅ What’s Included

🔌 Provider-Agnostic Email Adapter

  • Introduced a common EmailAdapter interface
  • Enables seamless swapping between providers (SendGrid, SES, Mailgun, etc.)
  • Adapter selection is environment-driven

🧪 Mock Email Provider

  • Safe mock provider for local development and CI
  • Prevents real email delivery outside production
  • Logs send attempts for visibility

📨 Templated Emails

  • Handlebars-based email templates
  • Templates created for:
    • Booking events (confirmation, cancellation)
    • Payment events (success, failure)
  • Clean separation between template structure and dynamic data

⚙️ Configuration

  • Provider selection via environment variables
  • Supports future providers with zero changes to consumers

📊 Logging

  • Centralized email logging (email.logger.ts)
  • Logs send attempts, successes, and failures
  • Ready for integration with centralized logging/tracing systems

🧪 Tests

  • Unit tests for:
    • Adapter behavior
    • Template rendering
    • Email service execution flow

🧩 Example Usage

await notify.sendEmail({
  to: user.email,
  subject: 'Booking Confirmed',
  template: 'booking/booking-confirmed',
  data: {
    userName: user.name,
    serviceName: booking.service,
    date: booking.date,
    reference: booking.ref,
  },
});

CLoses #149 

@ahmadogo ahmadogo merged commit 759dca7 into MentoNest:main Jan 29, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants